<?php

$action = getAction();

switch ($action) {
	case "index":
		$smarty->display("index.html");
		break;
	case "post":
		if($_POST) {
			$data["bm_phone"] = $_POST["mobile1"];
			$data["user_type"] = $_POST["user_type"];
			$data["user_name"] = $_POST["user_name"];
			$data["gift_phone"] = $_POST["mobile2"];
			$data["address"] = $_POST["address"];
			$data["insert_time"] = date("Y-m-d H:i:s");
			$data["update_time"] = date("Y-m-d H:i:s");
			
			$check = $db->getOne("select count(1) from " . table("user") . " where bm_phone = '". $data["bm_phone"] . "'");
			if($check) {
				$result["errmsg"] = "该手机已申请过此次活动";
				echo json_encode($result);
				exit();
			}
			
			$db->insert("user", $data);
				
			$result["succ"] = true;
			echo json_encode($result);
		}
		break;
}